var str = 'Apple is a big company,apple\'s logo is a APPLE, I like eat apple';
//1.替换apple为google
//console.log(str.replace('apple','google'));
//匹配模式-正则表达式
//console.log(str.replace(/apple/,'google'));
//匹配模式-全局匹配(global)-g
//console.log(str.replace(/apple/g,'google'));
//匹配模式-忽略大小写(ignore)-i
//console.log(str.replace(/apple/i,'google'));
//console.log(str.replace(/apple/ig,'google'));
//匹配
//console.log(str.match('apple'));
//返回数组
//var arr = str.match(/apple/ig);
//console.log(arr.length);
//查找
//console.log(str.search('apple'));
console.log(str.search(/apple1/i));
//如果查找不到，返回-1

//今天是星期五，马上就要duanwujie了，Duanwujie我要放假，旅游，DUANWUJIE还要吃粽子，duanwujie还可以看世界杯。
//1.查找duanwujie出现了多少次
//2.替换所有的duanwujie(不区分大小写)，为中文形式
var str = '今天是星期五，马上就要duanwujie了，Duanwujie我要放假，旅游，DUANWUJIE还要吃粽子，duanwujie还可以看世界杯。';
console.log(str.match(/duanwujie/ig).length);
console.log(str.replace(/duanwujie/ig,'端午节'));







